import { isValidDate } from "./isValidDate"

export function dateParse(date?: Date | string | number | null): Date | null {
  if (date == null) return null
  if (date instanceof Date) return date
  const d = new Date(date)
  if (!isValidDate(d)) return null
  return d
}
